<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActiveSupport::CoreExtensions::Time::Calculations</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActiveSupport::CoreExtensions::Time::Calculations</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../../files/vendor/rails/activesupport/lib/active_support/core_ext/time/calculations_rb.html">
                vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Enables the use of time calculations within Time itself
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000512">advance</a>&nbsp;&nbsp;
      <a href="#M000513">ago</a>&nbsp;&nbsp;
      <a href="#M000533">at_beginning_of_day</a>&nbsp;&nbsp;
      <a href="#M000536">at_beginning_of_month</a>&nbsp;&nbsp;
      <a href="#M000540">at_beginning_of_quarter</a>&nbsp;&nbsp;
      <a href="#M000526">at_beginning_of_week</a>&nbsp;&nbsp;
      <a href="#M000544">at_beginning_of_year</a>&nbsp;&nbsp;
      <a href="#M000538">at_end_of_month</a>&nbsp;&nbsp;
      <a href="#M000542">at_end_of_quarter</a>&nbsp;&nbsp;
      <a href="#M000528">at_end_of_week</a>&nbsp;&nbsp;
      <a href="#M000546">at_end_of_year</a>&nbsp;&nbsp;
      <a href="#M000532">at_midnight</a>&nbsp;&nbsp;
      <a href="#M000530">beginning_of_day</a>&nbsp;&nbsp;
      <a href="#M000535">beginning_of_month</a>&nbsp;&nbsp;
      <a href="#M000539">beginning_of_quarter</a>&nbsp;&nbsp;
      <a href="#M000524">beginning_of_week</a>&nbsp;&nbsp;
      <a href="#M000543">beginning_of_year</a>&nbsp;&nbsp;
      <a href="#M000511">change</a>&nbsp;&nbsp;
      <a href="#M000550">compare_with_coercion</a>&nbsp;&nbsp;
      <a href="#M000534">end_of_day</a>&nbsp;&nbsp;
      <a href="#M000537">end_of_month</a>&nbsp;&nbsp;
      <a href="#M000541">end_of_quarter</a>&nbsp;&nbsp;
      <a href="#M000527">end_of_week</a>&nbsp;&nbsp;
      <a href="#M000545">end_of_year</a>&nbsp;&nbsp;
      <a href="#M000509">future?</a>&nbsp;&nbsp;
      <a href="#M000515">in</a>&nbsp;&nbsp;
      <a href="#M000522">last_month</a>&nbsp;&nbsp;
      <a href="#M000520">last_year</a>&nbsp;&nbsp;
      <a href="#M000531">midnight</a>&nbsp;&nbsp;
      <a href="#M000549">minus_with_coercion</a>&nbsp;&nbsp;
      <a href="#M000525">monday</a>&nbsp;&nbsp;
      <a href="#M000516">months_ago</a>&nbsp;&nbsp;
      <a href="#M000517">months_since</a>&nbsp;&nbsp;
      <a href="#M000523">next_month</a>&nbsp;&nbsp;
      <a href="#M000529">next_week</a>&nbsp;&nbsp;
      <a href="#M000521">next_year</a>&nbsp;&nbsp;
      <a href="#M000507">past?</a>&nbsp;&nbsp;
      <a href="#M000510">seconds_since_midnight</a>&nbsp;&nbsp;
      <a href="#M000514">since</a>&nbsp;&nbsp;
      <a href="#M000508">today?</a>&nbsp;&nbsp;
      <a href="#M000548">tomorrow</a>&nbsp;&nbsp;
      <a href="#M000518">years_ago</a>&nbsp;&nbsp;
      <a href="#M000519">years_since</a>&nbsp;&nbsp;
      <a href="#M000547">yesterday</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">

    <div id="class-list">
      <h3 class="section-bar">Classes and Modules</h3>

      Module <a href="Calculations/ClassMethods.html" class="link">ActiveSupport::CoreExtensions::Time::Calculations::ClassMethods</a><br />

    </div>

    <div id="constants-list">
      <h3 class="section-bar">Constants</h3>

      <div class="name-list">
        <table summary="Constants">
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">COMMON_YEAR_DAYS_IN_MONTH</td>
          <td>=</td>
          <td class="context-item-value">[nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]</td>
        </tr>
        </table>
      </div>
    </div>



      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000512" class="method-detail">
        <a name="M000512"></a>

        <div class="method-heading">
          <a href="#M000512" class="method-signature">
          <span class="method-name">advance</span><span class="method-args">(options)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Uses Date to provide precise Time calculations for years, months, and days.
The <tt>options</tt> parameter takes a hash with any of these keys:
<tt>:years</tt>, <tt>:months</tt>, <tt>:weeks</tt>, <tt>:days</tt>,
<tt>:hours</tt>, <tt>:minutes</tt>, <tt>:seconds</tt>.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000512-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000512-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 102</span>
102:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">advance</span>(<span class="ruby-identifier">options</span>)
103:           <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:weeks</span>].<span class="ruby-identifier">nil?</span>
104:             <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:weeks</span>], <span class="ruby-identifier">partial_weeks</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:weeks</span>].<span class="ruby-identifier">divmod</span>(<span class="ruby-value">1</span>)
105:             <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:days</span>] = (<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:days</span>] <span class="ruby-operator">||</span> <span class="ruby-value">0</span>) <span class="ruby-operator">+</span> <span class="ruby-value">7</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">partial_weeks</span>
106:           <span class="ruby-keyword kw">end</span>
107:           
108:           <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:days</span>].<span class="ruby-identifier">nil?</span>
109:             <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:days</span>], <span class="ruby-identifier">partial_days</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:days</span>].<span class="ruby-identifier">divmod</span>(<span class="ruby-value">1</span>)
110:             <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:hours</span>] = (<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:hours</span>] <span class="ruby-operator">||</span> <span class="ruby-value">0</span>) <span class="ruby-operator">+</span> <span class="ruby-value">24</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">partial_days</span>
111:           <span class="ruby-keyword kw">end</span>
112:           
113:           <span class="ruby-identifier">d</span> = <span class="ruby-identifier">to_date</span>.<span class="ruby-identifier">advance</span>(<span class="ruby-identifier">options</span>)
114:           <span class="ruby-identifier">time_advanced_by_date</span> = <span class="ruby-identifier">change</span>(<span class="ruby-identifier">:year</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">d</span>.<span class="ruby-identifier">year</span>, <span class="ruby-identifier">:month</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">d</span>.<span class="ruby-identifier">month</span>, <span class="ruby-identifier">:day</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">d</span>.<span class="ruby-identifier">day</span>)
115:           <span class="ruby-identifier">seconds_to_advance</span> = (<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:seconds</span>] <span class="ruby-operator">||</span> <span class="ruby-value">0</span>) <span class="ruby-operator">+</span> (<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:minutes</span>] <span class="ruby-operator">||</span> <span class="ruby-value">0</span>) <span class="ruby-operator">*</span> <span class="ruby-value">60</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:hours</span>] <span class="ruby-operator">||</span> <span class="ruby-value">0</span>) <span class="ruby-operator">*</span> <span class="ruby-value">3600</span>
116:           <span class="ruby-identifier">seconds_to_advance</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">time_advanced_by_date</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">time_advanced_by_date</span>.<span class="ruby-identifier">since</span>(<span class="ruby-identifier">seconds_to_advance</span>)
117:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000513" class="method-detail">
        <a name="M000513"></a>

        <div class="method-heading">
          <a href="#M000513" class="method-signature">
          <span class="method-name">ago</span><span class="method-args">(seconds)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the time a number of seconds <a
href="Calculations.html#M000513">ago</a>, this is basically a wrapper
around the Numeric extension
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000513-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000513-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 120</span>
120:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ago</span>(<span class="ruby-identifier">seconds</span>)
121:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">since</span>(<span class="ruby-operator">-</span><span class="ruby-identifier">seconds</span>)
122:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000533" class="method-detail">
        <a name="M000533"></a>

        <div class="method-heading">
          <span class="method-name">at_beginning_of_day</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000530">beginning_of_day</a>
</p>
        </div>
      </div>

      <div id="method-M000536" class="method-detail">
        <a name="M000536"></a>

        <div class="method-heading">
          <span class="method-name">at_beginning_of_month</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000535">beginning_of_month</a>
</p>
        </div>
      </div>

      <div id="method-M000540" class="method-detail">
        <a name="M000540"></a>

        <div class="method-heading">
          <span class="method-name">at_beginning_of_quarter</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000539">beginning_of_quarter</a>
</p>
        </div>
      </div>

      <div id="method-M000526" class="method-detail">
        <a name="M000526"></a>

        <div class="method-heading">
          <span class="method-name">at_beginning_of_week</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000524">beginning_of_week</a>
</p>
        </div>
      </div>

      <div id="method-M000544" class="method-detail">
        <a name="M000544"></a>

        <div class="method-heading">
          <span class="method-name">at_beginning_of_year</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000543">beginning_of_year</a>
</p>
        </div>
      </div>

      <div id="method-M000538" class="method-detail">
        <a name="M000538"></a>

        <div class="method-heading">
          <span class="method-name">at_end_of_month</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000537">end_of_month</a>
</p>
        </div>
      </div>

      <div id="method-M000542" class="method-detail">
        <a name="M000542"></a>

        <div class="method-heading">
          <span class="method-name">at_end_of_quarter</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000541">end_of_quarter</a>
</p>
        </div>
      </div>

      <div id="method-M000528" class="method-detail">
        <a name="M000528"></a>

        <div class="method-heading">
          <span class="method-name">at_end_of_week</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000527">end_of_week</a>
</p>
        </div>
      </div>

      <div id="method-M000546" class="method-detail">
        <a name="M000546"></a>

        <div class="method-heading">
          <span class="method-name">at_end_of_year</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000545">end_of_year</a>
</p>
        </div>
      </div>

      <div id="method-M000532" class="method-detail">
        <a name="M000532"></a>

        <div class="method-heading">
          <span class="method-name">at_midnight</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000530">beginning_of_day</a>
</p>
        </div>
      </div>

      <div id="method-M000530" class="method-detail">
        <a name="M000530"></a>

        <div class="method-heading">
          <a href="#M000530" class="method-signature">
          <span class="method-name">beginning_of_day</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the start of the day (0:00)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000530-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000530-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 203</span>
203:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginning_of_day</span>
204:           <span class="ruby-comment cmt">#(self - seconds_since_midnight).change(:usec =&gt; 0)</span>
205:           <span class="ruby-identifier">change</span>(<span class="ruby-identifier">:hour</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">:min</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">:sec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">:usec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>)
206:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000535" class="method-detail">
        <a name="M000535"></a>

        <div class="method-heading">
          <a href="#M000535" class="method-signature">
          <span class="method-name">beginning_of_month</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the start of the month (1st of the month,
0:00)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000535-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000535-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 217</span>
217:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginning_of_month</span>
218:           <span class="ruby-comment cmt">#self - ((self.mday-1).days + self.seconds_since_midnight)</span>
219:           <span class="ruby-identifier">change</span>(<span class="ruby-identifier">:day</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>,<span class="ruby-identifier">:hour</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">:min</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">:sec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">:usec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>)
220:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000539" class="method-detail">
        <a name="M000539"></a>

        <div class="method-heading">
          <a href="#M000539" class="method-signature">
          <span class="method-name">beginning_of_quarter</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the start of the quarter (1st of january,
april, july, october, 0:00)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000539-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000539-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 232</span>
232:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginning_of_quarter</span>
233:           <span class="ruby-identifier">beginning_of_month</span>.<span class="ruby-identifier">change</span>(<span class="ruby-identifier">:month</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value">10</span>, <span class="ruby-value">7</span>, <span class="ruby-value">4</span>, <span class="ruby-value">1</span>].<span class="ruby-identifier">detect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">m</span><span class="ruby-operator">|</span> <span class="ruby-identifier">m</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">month</span> })
234:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000524" class="method-detail">
        <a name="M000524"></a>

        <div class="method-heading">
          <a href="#M000524" class="method-signature">
          <span class="method-name">beginning_of_week</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the &quot;start&quot; of this week (Monday,
0:00)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000524-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000524-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 182</span>
182:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginning_of_week</span>
183:           <span class="ruby-identifier">days_to_monday</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">wday!</span>=<span class="ruby-value">0</span> <span class="ruby-operator">?</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">wday</span><span class="ruby-operator">-</span><span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-value">6</span>
184:           (<span class="ruby-keyword kw">self</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">days_to_monday</span>.<span class="ruby-identifier">days</span>).<span class="ruby-identifier">midnight</span>
185:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000543" class="method-detail">
        <a name="M000543"></a>

        <div class="method-heading">
          <a href="#M000543" class="method-signature">
          <span class="method-name">beginning_of_year</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the start of the year (1st of january,
0:00)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000543-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000543-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 244</span>
244:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginning_of_year</span>
245:           <span class="ruby-identifier">change</span>(<span class="ruby-identifier">:month</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>,<span class="ruby-identifier">:day</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>,<span class="ruby-identifier">:hour</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">:min</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">:sec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">:usec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>)
246:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000511" class="method-detail">
        <a name="M000511"></a>

        <div class="method-heading">
          <a href="#M000511" class="method-signature">
          <span class="method-name">change</span><span class="method-args">(options)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time where one or more of the elements have been changed
according to the <tt>options</tt> parameter. The time options (hour,
minute, sec, usec) reset cascadingly, so if only the hour is passed, then
minute, sec, and usec is set to 0. If the hour and minute is passed, then
sec and usec is set to 0.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000511-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000511-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 85</span>
85:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">change</span>(<span class="ruby-identifier">options</span>)
86:           <span class="ruby-operator">::</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">send</span>(
87:             <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">utc?</span> <span class="ruby-value">? </span><span class="ruby-operator">:</span><span class="ruby-identifier">utc_time</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">:local_time</span>,
88:             <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:year</span>]  <span class="ruby-operator">||</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">year</span>,
89:             <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:month</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">month</span>,
90:             <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:day</span>]   <span class="ruby-operator">||</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">day</span>,
91:             <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:hour</span>]  <span class="ruby-operator">||</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">hour</span>,
92:             <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:min</span>]   <span class="ruby-operator">||</span> (<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:hour</span>] <span class="ruby-operator">?</span> <span class="ruby-value">0</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">min</span>),
93:             <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:sec</span>]   <span class="ruby-operator">||</span> ((<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:hour</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:min</span>]) <span class="ruby-operator">?</span> <span class="ruby-value">0</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">sec</span>),
94:             <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:usec</span>]  <span class="ruby-operator">||</span> ((<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:hour</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:min</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:sec</span>]) <span class="ruby-operator">?</span> <span class="ruby-value">0</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">usec</span>)
95:           )
96:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000550" class="method-detail">
        <a name="M000550"></a>

        <div class="method-heading">
          <a href="#M000550" class="method-signature">
          <span class="method-name">compare_with_coercion</span><span class="method-args">(other)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Layers additional behavior on Time#&lt;=&gt; so that DateTime and <a
href="../../TimeWithZone.html">ActiveSupport::TimeWithZone</a> instances
can be chronologically compared with a Time
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000550-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000550-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 291</span>
291:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">compare_with_coercion</span>(<span class="ruby-identifier">other</span>)
292:           <span class="ruby-comment cmt"># if other is an ActiveSupport::TimeWithZone, coerce a Time instance from it so we can do &lt;=&gt; comparison</span>
293:           <span class="ruby-identifier">other</span> = <span class="ruby-identifier">other</span>.<span class="ruby-identifier">comparable_time</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:comparable_time</span>)
294:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">acts_like?</span>(<span class="ruby-identifier">:date</span>)
295:             <span class="ruby-comment cmt"># other is a Date/DateTime, so coerce self #to_datetime and hand off to DateTime#&lt;=&gt;</span>
296:             <span class="ruby-identifier">to_datetime</span>.<span class="ruby-identifier">compare_without_coercion</span>(<span class="ruby-identifier">other</span>)
297:           <span class="ruby-keyword kw">else</span>
298:             <span class="ruby-identifier">compare_without_coercion</span>(<span class="ruby-identifier">other</span>)
299:           <span class="ruby-keyword kw">end</span>
300:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000534" class="method-detail">
        <a name="M000534"></a>

        <div class="method-heading">
          <a href="#M000534" class="method-signature">
          <span class="method-name">end_of_day</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the end of the day (23:59:59)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000534-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000534-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 212</span>
212:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">end_of_day</span>
213:           <span class="ruby-identifier">change</span>(<span class="ruby-identifier">:hour</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">23</span>, <span class="ruby-identifier">:min</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">59</span>, <span class="ruby-identifier">:sec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">59</span>)
214:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000537" class="method-detail">
        <a name="M000537"></a>

        <div class="method-heading">
          <a href="#M000537" class="method-signature">
          <span class="method-name">end_of_month</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the end of the month (last day of the
month, 0:00)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000537-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000537-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 224</span>
224:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">end_of_month</span>
225:           <span class="ruby-comment cmt">#self - ((self.mday-1).days + self.seconds_since_midnight)</span>
226:           <span class="ruby-identifier">last_day</span> = <span class="ruby-operator">::</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">days_in_month</span>( <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">month</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">year</span> )
227:           <span class="ruby-identifier">change</span>(<span class="ruby-identifier">:day</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">last_day</span>, <span class="ruby-identifier">:hour</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">23</span>, <span class="ruby-identifier">:min</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">59</span>, <span class="ruby-identifier">:sec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">59</span>, <span class="ruby-identifier">:usec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>)
228:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000541" class="method-detail">
        <a name="M000541"></a>

        <div class="method-heading">
          <a href="#M000541" class="method-signature">
          <span class="method-name">end_of_quarter</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the end of the quarter (last day of march,
june, september, december, 23:59:59)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000541-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000541-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 238</span>
238:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">end_of_quarter</span>
239:           <span class="ruby-identifier">beginning_of_month</span>.<span class="ruby-identifier">change</span>(<span class="ruby-identifier">:month</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value">3</span>, <span class="ruby-value">6</span>, <span class="ruby-value">9</span>, <span class="ruby-value">12</span>].<span class="ruby-identifier">detect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">m</span><span class="ruby-operator">|</span> <span class="ruby-identifier">m</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">month</span> }).<span class="ruby-identifier">end_of_month</span>
240:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000527" class="method-detail">
        <a name="M000527"></a>

        <div class="method-heading">
          <a href="#M000527" class="method-signature">
          <span class="method-name">end_of_week</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the end of this week (Sunday, 23:59:59)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000527-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000527-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 190</span>
190:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">end_of_week</span>
191:           <span class="ruby-identifier">days_to_sunday</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">wday!</span>=<span class="ruby-value">0</span> <span class="ruby-operator">?</span> <span class="ruby-value">7</span><span class="ruby-operator">-</span><span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">wday</span> <span class="ruby-operator">:</span> <span class="ruby-value">0</span>
192:           (<span class="ruby-keyword kw">self</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">days_to_sunday</span>.<span class="ruby-identifier">days</span>).<span class="ruby-identifier">end_of_day</span>
193:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000545" class="method-detail">
        <a name="M000545"></a>

        <div class="method-heading">
          <a href="#M000545" class="method-signature">
          <span class="method-name">end_of_year</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the end of the year (31st of december,
23:59:59)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000545-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000545-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 250</span>
250:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">end_of_year</span>
251:           <span class="ruby-identifier">change</span>(<span class="ruby-identifier">:month</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">12</span>,<span class="ruby-identifier">:day</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">31</span>,<span class="ruby-identifier">:hour</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">23</span>, <span class="ruby-identifier">:min</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">59</span>, <span class="ruby-identifier">:sec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">59</span>)
252:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000509" class="method-detail">
        <a name="M000509"></a>

        <div class="method-heading">
          <a href="#M000509" class="method-signature">
          <span class="method-name">future?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Tells whether the Time object&#8216;s time lies <a
href="Calculations.html#M000515">in</a> the future
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000509-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000509-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 73</span>
73:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">future?</span>
74:           <span class="ruby-keyword kw">self</span> <span class="ruby-operator">&gt;</span> <span class="ruby-operator">::</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">current</span>
75:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000515" class="method-detail">
        <a name="M000515"></a>

        <div class="method-heading">
          <span class="method-name">in</span><span class="method-args">(seconds)</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000514">since</a>
</p>
        </div>
      </div>

      <div id="method-M000522" class="method-detail">
        <a name="M000522"></a>

        <div class="method-heading">
          <a href="#M000522" class="method-signature">
          <span class="method-name">last_month</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Short-hand for <a href="Calculations.html#M000516">months_ago</a>(1)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000522-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000522-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 172</span>
172:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">last_month</span>
173:           <span class="ruby-identifier">months_ago</span>(<span class="ruby-value">1</span>)
174:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000520" class="method-detail">
        <a name="M000520"></a>

        <div class="method-heading">
          <a href="#M000520" class="method-signature">
          <span class="method-name">last_year</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Short-hand for <a href="Calculations.html#M000518">years_ago</a>(1)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000520-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000520-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 161</span>
161:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">last_year</span>
162:           <span class="ruby-identifier">years_ago</span>(<span class="ruby-value">1</span>)
163:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000531" class="method-detail">
        <a name="M000531"></a>

        <div class="method-heading">
          <span class="method-name">midnight</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000530">beginning_of_day</a>
</p>
        </div>
      </div>

      <div id="method-M000549" class="method-detail">
        <a name="M000549"></a>

        <div class="method-heading">
          <a href="#M000549" class="method-signature">
          <span class="method-name">minus_with_coercion</span><span class="method-args">(other)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Time#- can also be used to determine the number of seconds between two Time
instances. We&#8216;re layering on additional behavior so that <a
href="../../TimeWithZone.html">ActiveSupport::TimeWithZone</a> instances
are coerced into values that Time#- will recognize
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000549-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000549-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 284</span>
284:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">minus_with_coercion</span>(<span class="ruby-identifier">other</span>)
285:           <span class="ruby-identifier">other</span> = <span class="ruby-identifier">other</span>.<span class="ruby-identifier">comparable_time</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:comparable_time</span>)
286:           <span class="ruby-identifier">minus_without_coercion</span>(<span class="ruby-identifier">other</span>)
287:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000525" class="method-detail">
        <a name="M000525"></a>

        <div class="method-heading">
          <span class="method-name">monday</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000524">beginning_of_week</a>
</p>
        </div>
      </div>

      <div id="method-M000516" class="method-detail">
        <a name="M000516"></a>

        <div class="method-heading">
          <a href="#M000516" class="method-signature">
          <span class="method-name">months_ago</span><span class="method-args">(months)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the time a number of specified months <a
href="Calculations.html#M000513">ago</a>
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000516-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000516-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 141</span>
141:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">months_ago</span>(<span class="ruby-identifier">months</span>)
142:           <span class="ruby-identifier">advance</span>(<span class="ruby-identifier">:months</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-operator">-</span><span class="ruby-identifier">months</span>)
143:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000517" class="method-detail">
        <a name="M000517"></a>

        <div class="method-heading">
          <a href="#M000517" class="method-signature">
          <span class="method-name">months_since</span><span class="method-args">(months)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the time a number of specified months <a
href="Calculations.html#M000515">in</a> the future
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000517-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000517-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 146</span>
146:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">months_since</span>(<span class="ruby-identifier">months</span>)
147:           <span class="ruby-identifier">advance</span>(<span class="ruby-identifier">:months</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">months</span>)
148:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000523" class="method-detail">
        <a name="M000523"></a>

        <div class="method-heading">
          <a href="#M000523" class="method-signature">
          <span class="method-name">next_month</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Short-hand for <a href="Calculations.html#M000517">months_since</a>(1)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000523-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000523-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 177</span>
177:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">next_month</span>
178:           <span class="ruby-identifier">months_since</span>(<span class="ruby-value">1</span>)
179:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000529" class="method-detail">
        <a name="M000529"></a>

        <div class="method-heading">
          <a href="#M000529" class="method-signature">
          <span class="method-name">next_week</span><span class="method-args">(day = :monday)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the start of the given day <a
href="Calculations.html#M000515">in</a> next week (default is Monday).
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000529-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000529-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 197</span>
197:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">next_week</span>(<span class="ruby-identifier">day</span> = <span class="ruby-identifier">:monday</span>)
198:           <span class="ruby-identifier">days_into_week</span> = { <span class="ruby-identifier">:monday</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">:tuesday</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>, <span class="ruby-identifier">:wednesday</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">2</span>, <span class="ruby-identifier">:thursday</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">3</span>, <span class="ruby-identifier">:friday</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">4</span>, <span class="ruby-identifier">:saturday</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">5</span>, <span class="ruby-identifier">:sunday</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">6</span>}
199:           <span class="ruby-identifier">since</span>(<span class="ruby-value">1</span>.<span class="ruby-identifier">week</span>).<span class="ruby-identifier">beginning_of_week</span>.<span class="ruby-identifier">since</span>(<span class="ruby-identifier">days_into_week</span>[<span class="ruby-identifier">day</span>].<span class="ruby-identifier">day</span>).<span class="ruby-identifier">change</span>(<span class="ruby-identifier">:hour</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>)
200:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000521" class="method-detail">
        <a name="M000521"></a>

        <div class="method-heading">
          <a href="#M000521" class="method-signature">
          <span class="method-name">next_year</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Short-hand for <a href="Calculations.html#M000519">years_since</a>(1)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000521-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000521-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 166</span>
166:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">next_year</span>
167:           <span class="ruby-identifier">years_since</span>(<span class="ruby-value">1</span>)
168:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000507" class="method-detail">
        <a name="M000507"></a>

        <div class="method-heading">
          <a href="#M000507" class="method-signature">
          <span class="method-name">past?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Tells whether the Time object&#8216;s time lies <a
href="Calculations.html#M000515">in</a> the past
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000507-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000507-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 63</span>
63:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">past?</span>
64:           <span class="ruby-keyword kw">self</span> <span class="ruby-operator">&lt;</span> <span class="ruby-operator">::</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">current</span>
65:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000510" class="method-detail">
        <a name="M000510"></a>

        <div class="method-heading">
          <a href="#M000510" class="method-signature">
          <span class="method-name">seconds_since_midnight</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Seconds <a href="Calculations.html#M000514">since</a> <a
href="Calculations.html#M000531">midnight</a>: Time.now.<a
href="Calculations.html#M000510">seconds_since_midnight</a>
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000510-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000510-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 78</span>
78:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">seconds_since_midnight</span>
79:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">-</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">change</span>(<span class="ruby-identifier">:hour</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>).<span class="ruby-identifier">to_i</span> <span class="ruby-operator">+</span> (<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">usec</span><span class="ruby-operator">/</span><span class="ruby-value">1.0e+6</span>)
80:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000514" class="method-detail">
        <a name="M000514"></a>

        <div class="method-heading">
          <a href="#M000514" class="method-signature">
          <span class="method-name">since</span><span class="method-args">(seconds)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the time a number of seconds <a
href="Calculations.html#M000514">since</a> the instance time, this is
basically a wrapper around the Numeric extension.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000514-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000514-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 126</span>
126:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">since</span>(<span class="ruby-identifier">seconds</span>)
127:           <span class="ruby-identifier">f</span> = <span class="ruby-identifier">seconds</span>.<span class="ruby-identifier">since</span>(<span class="ruby-keyword kw">self</span>)
128:           <span class="ruby-keyword kw">if</span> <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">Duration</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">seconds</span>
129:             <span class="ruby-identifier">f</span>
130:           <span class="ruby-keyword kw">else</span>
131:             <span class="ruby-identifier">initial_dst</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">dst?</span> <span class="ruby-value">? </span><span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-value">0</span>
132:             <span class="ruby-identifier">final_dst</span>   = <span class="ruby-identifier">f</span>.<span class="ruby-identifier">dst?</span> <span class="ruby-value">? </span><span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-value">0</span>
133:             (<span class="ruby-identifier">seconds</span>.<span class="ruby-identifier">abs</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">86400</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">initial_dst</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">final_dst</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">f</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">initial_dst</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">final_dst</span>).<span class="ruby-identifier">hours</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">f</span>
134:           <span class="ruby-keyword kw">end</span>
135:         <span class="ruby-keyword kw">rescue</span>
136:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_datetime</span>.<span class="ruby-identifier">since</span>(<span class="ruby-identifier">seconds</span>)
137:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000508" class="method-detail">
        <a name="M000508"></a>

        <div class="method-heading">
          <a href="#M000508" class="method-signature">
          <span class="method-name">today?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Tells whether the Time object&#8216;s time is today
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000508-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000508-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 68</span>
68:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">today?</span>
69:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_date</span> <span class="ruby-operator">==</span> <span class="ruby-operator">::</span><span class="ruby-constant">Date</span>.<span class="ruby-identifier">current</span>
70:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000548" class="method-detail">
        <a name="M000548"></a>

        <div class="method-heading">
          <a href="#M000548" class="method-signature">
          <span class="method-name">tomorrow</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Convenience method which returns a new Time representing the time 1 day <a
href="Calculations.html#M000514">since</a> the instance time
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000548-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000548-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 261</span>
261:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">tomorrow</span>
262:           <span class="ruby-identifier">advance</span>(<span class="ruby-identifier">:days</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>)
263:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000518" class="method-detail">
        <a name="M000518"></a>

        <div class="method-heading">
          <a href="#M000518" class="method-signature">
          <span class="method-name">years_ago</span><span class="method-args">(years)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the time a number of specified years <a
href="Calculations.html#M000513">ago</a>
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000518-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000518-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 151</span>
151:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">years_ago</span>(<span class="ruby-identifier">years</span>)
152:           <span class="ruby-identifier">advance</span>(<span class="ruby-identifier">:years</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-operator">-</span><span class="ruby-identifier">years</span>)
153:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000519" class="method-detail">
        <a name="M000519"></a>

        <div class="method-heading">
          <a href="#M000519" class="method-signature">
          <span class="method-name">years_since</span><span class="method-args">(years)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the time a number of specified years <a
href="Calculations.html#M000515">in</a> the future
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000519-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000519-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 156</span>
156:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">years_since</span>(<span class="ruby-identifier">years</span>)
157:           <span class="ruby-identifier">advance</span>(<span class="ruby-identifier">:years</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">years</span>)
158:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000547" class="method-detail">
        <a name="M000547"></a>

        <div class="method-heading">
          <a href="#M000547" class="method-signature">
          <span class="method-name">yesterday</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Convenience method which returns a new Time representing the time 1 day <a
href="Calculations.html#M000513">ago</a>
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000547-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000547-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 256</span>
256:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">yesterday</span>
257:           <span class="ruby-identifier">advance</span>(<span class="ruby-identifier">:days</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">-1</span>)
258:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>